Knowing String Manipulation Through C Language (C-Series Book 2) by Debajyoti Bhattacharjee

Knowing String Manipulation Through C Language (C-Series Book 2) by Debajyoti Bhattacharjee

Author:Debajyoti Bhattacharjee [Bhattacharjee, Debajyoti]
Language: eng
Format: epub
Publisher: UNKNOWN
Published: 2018-07-11T23:00:00+00:00


3. Write a program to arrange the name list in ascending order. #include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

char name [30][30] ,temp[30];

int i ,n , j;

clrcsr ();

printf (“\n Number of names : “); scanf (“%d “,&n);

for(i=0 ; i<n ; i++)

{

printf (“\n Name[%d] : “ ,(i+1)); scanf(“%s “,name[i] );

}

for(i=0 ; i<n ; i++)

{

for(j=1+I ; j<n-1 ; j++)

If( strcmp (name[i], name[j])>0) strcpy(temp , name[i]); strcpy(name[i] , name[j]); strcpy(name[j] , temp); }

for(i=0 ; i<n ; i++)

{

printf(“\n %s “,name[i]); }

getch();

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.